package gearunits.models  {
	import sandy.primitive.Primitive3D;
	import sandy.core.scenegraph.Geometry3D;
	import sandy.core.scenegraph.Shape3D;

	public class SMeshBuildingMechFactory extends Shape3D implements Primitive3D {
		private var l:Geometry3D;

		private function f(v1:Number,v2:Number,v3:Number,uv00:Number,uv01:Number,uv10:Number,uv11:Number,uv20:Number,uv21:Number,normX:Number,normY:Number,normZ:Number):void {
			var uv1:Number = l.getNextUVCoordID();
			var uv2:Number = uv1 + 1;
			var uv3:Number = uv2 + 1;

			l.setUVCoords(uv1,uv00,1-uv01);
			l.setUVCoords(uv2,uv10,1-uv11);
			l.setUVCoords(uv3,uv20,1-uv21);

			l.setFaceVertexIds(l.getNextFaceID(), v1,v2,v3);
			l.setFaceUVCoordsIds(l.getNextFaceUVCoordID(), uv1,uv2,uv3);
			l.setFaceNormal(l.getNextFaceNormalID(), normX,normZ,normY);
		}

		private function f4(v1:Number,v2:Number,v3:Number,v4:Number,uv00:Number,uv01:Number,uv10:Number,uv11:Number,uv20:Number,uv21:Number,uv30:Number,uv31:Number,normX:Number,normY:Number,normZ:Number):void {
			var uv1:Number = l.getNextUVCoordID();
			var uv2:Number = uv1 + 1;
			var uv3:Number = uv2 + 1;
			var uv4:Number = uv3 + 1;

			l.setUVCoords(uv1,uv00,1-uv01);
			l.setUVCoords(uv2,uv10,1-uv11);
			l.setUVCoords(uv3,uv20,1-uv21);
			l.setUVCoords(uv4,uv30,1-uv31);

			l.setFaceVertexIds(l.getNextFaceID(),v1,v2,v3,v4);
			l.setFaceUVCoordsIds(l.getNextFaceUVCoordID(),uv1,uv2,uv3,uv4);
			l.setFaceNormal(l.getNextFaceNormalID(),normX,normZ,normY);
		}

		private function f2(v1:Number,v2:Number,v3:Number):void {
			l.setFaceVertexIds(l.getNextFaceID(), v1,v2,v3);
		}

		private function v(vx:Number,vy:Number,vz:Number):void {
			l.setVertex(l.getNextVertexID(),vx,vz,vy);
		}

		public function SMeshBuildingMechFactory( p_Name:String=null ) {
			super( p_Name );
			geometry = generate();
		}

		public function generate(... arguments):Geometry3D {
			l = new Geometry3D();
			v(16.000000,13.000000,0.000000);
			v(16.000000,-13.000000,0.000000);
			v(-16.000002,-12.999996,0.000000);
			v(-15.999992,13.000006,0.000000);
			v(15.000008,12.999992,16.000000);
			v(14.999990,-13.000010,16.000000);
			v(-15.000006,-12.999994,16.000000);
			v(-14.999998,13.000000,16.000000);
			v(-16.499998,13.000000,17.599998);
			v(16.500008,12.999991,17.599998);
			v(-17.599993,13.000007,-0.000000);
			v(17.600000,13.000000,-0.000000);
			v(17.600000,16.000000,0.000001);
			v(-17.599993,16.000008,0.000001);
			v(16.500008,15.999991,17.600000);
			v(-16.499998,16.000000,17.600000);
			v(-16.500006,-12.999993,17.599998);
			v(16.499990,-13.000010,17.599998);
			v(-17.600002,-12.999996,-0.000000);
			v(17.600000,-13.000000,-0.000000);
			v(17.600000,-16.000000,-0.000001);
			v(-17.600002,-15.999996,-0.000001);
			v(16.499990,-16.000011,17.599998);
			v(-16.500006,-15.999993,17.599998);

			f(20,22,21,0.535453,0.344095,0.736825,0.356061,0.536688,0.746762,-0.000000,-1.000000,-0.000001);
			f(22,23,21,0.736825,0.356061,0.737983,0.733561,0.536688,0.746762,-0.000001,-1.000000,0.000000);
			f(16,18,23,0.738602,0.948594,0.737983,0.746867,0.772920,0.948488,-0.998053,0.000000,0.062378);
			f(18,21,23,0.737983,0.746867,0.772301,0.746762,0.772920,0.948488,-0.998053,-0.000000,0.062378);
			f(19,17,20,0.842175,0.746762,0.842794,0.948488,0.807857,0.746867,0.998053,0.000000,0.062379);
			f(17,22,20,0.842794,0.948488,0.808476,0.948594,0.807857,0.746867,0.998053,-0.000000,0.062379);
			f(17,16,23,0.273560,0.402878,0.272402,0.780378,0.238084,0.780273,-0.000000,0.000000,1.000000);
			f(17,23,22,0.273560,0.402878,0.238084,0.780273,0.239242,0.402773,0.000000,-0.000000,1.000000);
			f(18,19,20,0.236849,0.402773,0.238084,0.805440,0.203766,0.805545,0.000000,0.000000,-1.000000);
			f(18,20,21,0.236849,0.402773,0.203766,0.805545,0.202530,0.402878,0.000000,0.000000,-1.000000);
			f(2,1,19,0.334101,0.362398,0.332978,0.728459,0.332922,0.746762,0.000000,0.683941,0.729537);
			f(2,19,18,0.334101,0.362398,0.332922,0.746762,0.334158,0.344095,0.000000,0.717900,-0.696146);
			f(5,6,16,0.516044,0.717581,0.517097,0.374399,0.535453,0.357296,0.000001,1.000000,-0.000000);
			f(5,16,17,0.516044,0.717581,0.535453,0.357296,0.534294,0.734796,0.000001,1.000000,0.000000);
			f(1,5,19,0.332978,0.728459,0.516044,0.717581,0.332922,0.746762,0.000000,1.000000,0.000001);
			f(5,17,19,0.516044,0.717581,0.534294,0.734796,0.332922,0.746762,0.000000,1.000000,0.000001);
			f(6,2,18,0.517097,0.374399,0.334101,0.362398,0.334158,0.344095,0.000000,1.000000,-0.000000);
			f(6,18,16,0.517097,0.374399,0.334158,0.344095,0.535453,0.357296,0.000000,1.000000,-0.000000);
			f(14,12,13,0.202530,0.792239,0.001235,0.805440,0.000000,0.402773,0.000000,1.000000,0.000001);
			f(14,13,15,0.202530,0.792239,0.000000,0.402773,0.201372,0.414738,0.000000,1.000000,0.000000);
			f(10,8,13,0.772920,0.948488,0.773539,0.746762,0.807238,0.948594,-0.998053,-0.000000,0.062378);
			f(8,15,13,0.773539,0.746762,0.807857,0.746867,0.807238,0.948594,-0.998053,-0.000000,0.062378);
			f(9,11,12,0.843413,0.948594,0.842794,0.746867,0.877112,0.746762,0.998053,-0.000000,0.062378);
			f(9,12,14,0.843413,0.948594,0.877112,0.746762,0.877731,0.948488,0.998053,-0.000000,0.062378);
			f(8,9,14,0.297446,0.780273,0.298604,0.402773,0.332922,0.402878,-0.000000,-0.000001,1.000000);
			f(8,14,15,0.297446,0.780273,0.332922,0.402878,0.331764,0.780379,-0.000000,-0.000001,1.000000);
			f(11,10,13,0.298604,0.402773,0.297369,0.000105,0.331687,0.000000,0.000000,0.000000,-1.000000);
			f(11,13,12,0.298604,0.402773,0.331687,0.000000,0.332922,0.402667,0.000000,0.000000,-1.000000);
			f(0,3,10,0.298548,0.384469,0.297425,0.018408,0.297369,0.000105,-0.000000,-0.258736,-0.965948);
			f(0,10,11,0.298548,0.384469,0.297369,0.000105,0.298604,0.402773,-0.000000,-0.507692,-0.861539);
			f(7,4,9,0.921105,0.717581,0.922158,0.374399,0.940513,0.357296,-0.000000,-1.000000,-0.000000);
			f(7,9,8,0.921105,0.717581,0.940513,0.357296,0.939355,0.734796,-0.000000,-1.000000,-0.000000);
			f(4,0,11,0.922158,0.374399,0.739162,0.362398,0.739218,0.344095,-0.000000,-1.000000,-0.000000);
			f(4,11,9,0.922158,0.374399,0.739218,0.344095,0.940513,0.357296,-0.000000,-1.000000,-0.000000);
			f(3,7,10,0.738039,0.728459,0.921105,0.717581,0.737983,0.746762,-0.000001,-1.000000,-0.000000);
			f(7,8,10,0.921105,0.717581,0.939355,0.734796,0.737983,0.746762,-0.000000,-1.000000,-0.000000);
			f(2,6,7,0.631400,0.000563,0.814787,0.000000,0.815700,0.297425,-0.998053,0.000000,0.062378);
			f(2,7,3,0.631400,0.000563,0.815700,0.297425,0.632312,0.297987,-0.998053,0.000000,0.062378);
			f(0,4,1,0.815700,0.000563,0.999088,0.000000,0.816612,0.297987,0.998053,0.000000,0.062378);
			f(4,5,1,0.999088,0.000000,1.000000,0.297425,0.816612,0.297987,0.998053,-0.000001,0.062379);
			f(4,7,5,0.631400,0.000912,0.630347,0.344095,0.333975,0.000000,-0.000000,-0.000000,1.000000);
			f(7,6,5,0.630347,0.344095,0.332922,0.343182,0.333975,0.000000,0.000000,-0.000000,1.000000);
			f(0,1,2,0.298548,0.384469,0.001123,0.385382,0.000000,0.019321,0.000000,0.000000,-1.000000);
			f(0,2,3,0.298548,0.384469,0.000000,0.019321,0.297425,0.018408,0.000000,-0.000000,-1.000000);

			this.x = 0.000000;
			this.y = 0.000000;
			this.z = 0.000000;

			this.rotateX = 0.000000;
			this.rotateY = 0.000000;
			this.rotateZ = 0.000000;

			this.scaleX = 1.000000;
			this.scaleY = 1.000000;
			this.scaleZ = 1.000000;
			return (l);
		}
	}
}